package com.fdb.efp.esb.service.impl.hlw;

import com.fdb.efp.esb.common.client.resp.EsbRespSysHeadBean;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.fdb.efp.esb.service.bo.req.hlw.ReqAlarmJudgementBean;
import com.fdb.efp.esb.service.bo.resp.hlw.RespAlarmJudgementBean;
import com.fdb.efp.esb.service.client.ESBClientFactory;
import com.fdb.efp.esb.service.facade.hlw.AlarmJudgementService;

/**
 * 告警判断接口
  * @author heyingfeng
  * @since 2019年1月24日 下午3:14:43
  * @version 1.0
 */
@Service("alarmJudgementService")
public class AlarmJudgementServiceImpl implements AlarmJudgementService {
	
	/**
	 * 日志记录
	 */
	Logger logger = LoggerFactory.getLogger(AlarmJudgementServiceImpl.class);

	@Override
	public RespAlarmJudgementBean alarmJudgement(ReqAlarmJudgementBean reqAlarmJudgementBean) throws Exception {
		// 返回对象
		RespAlarmJudgementBean respAlarmJudgementBean = new RespAlarmJudgementBean();
		EsbRespSysHeadBean esbRespSysHeadBean = new EsbRespSysHeadBean();
		logger.debug("监控对象名称：" + reqAlarmJudgementBean.getMonObjNm() + "开始");
		try {
			// 1.调用ESB客户端服务
			esbRespSysHeadBean = ESBClientFactory.buildClient().withBody(reqAlarmJudgementBean).withTradeNo("60120002")
				.withScene("01").create().sendAndReceive().getSysHead();
			respAlarmJudgementBean.setRetCd(esbRespSysHeadBean.getRetInfArry().get(0).getRetCd());
			respAlarmJudgementBean.setRetMsg(esbRespSysHeadBean.getRetInfArry().get(0).getRetMsg());
			logger.debug("调用告警判断接口返回成功！请求参数：" + reqAlarmJudgementBean + "***********返回结果:" + respAlarmJudgementBean);
		} catch (Exception e) {
			logger.debug("调用告警判断接口失败！"+e.getMessage());
			throw e;
		}
		return respAlarmJudgementBean;
	}

}
